package com.tangruojie.utils;

import com.tangruojie.properties.MyAppProperties;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller;

import java.io.File;

/**
 * 工具类：加载并解析 XML 为 JavaBean
 */
public class XmlLoader {

    public static MyAppProperties loadFromXml(String path) throws Exception {
        JAXBContext context = JAXBContext.newInstance(MyAppProperties.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        return (MyAppProperties) unmarshaller.unmarshal(new File(path));
    }

}
